package edu.asu.sapa.ground.update;

import java.util.ArrayList;

import edu.asu.sapa.Planner;
import edu.asu.sapa.ground.MathForm;
import edu.asu.sapa.ground.PropDB;
import edu.asu.sapa.ground.Proposition;
import edu.asu.sapa.ground.State;
import edu.asu.sapa.ground.PropDB.Entry;
import edu.asu.sapa.heuristic.PG;

public class WeakCondition extends Condition {

	public WeakCondition() {}
	
	public WeakCondition(Proposition p, int id, boolean value) {
		this.p = p;
		this.id = id;
		this.value = value;
	}

	public WeakCondition(WeakCondition c) {
		this.id = c.id;
		this.isConstant = c.isConstant;
		this.value = c.value;
		this.p = c.p;
	}

	public void relaxedUpdate(PG pg, State s, Context c, float time) {
		if (value)
			pg.addGoal(id,time+Planner.EPSILON);
	}
	public void relaxedStart(PG pg, State s, Context c, float time) {
		if (value)
			pg.addGoal(id,time+Planner.EPSILON);
	}
	public void relaxedFinish(PG pg, State S, Context c, float time) {
	}
	
	public boolean updateBefore(State s, Context c, float time) {
		return true;
	}
	
	public boolean updateAfter(State s, Context c, float time) {
		return true;
	}

	public boolean startBefore(State s, Context c, float time) {
		s.addConstraint(this,c);
		return true;
	}
	
	public boolean startAfter(State s, Context c, float time) {
		s.addConstraint(this,c);
		return true;
	}
	
	public boolean finishBefore(State s, Context c, float time) {
		s.removeConstraint(this,c);
		return true;
	}
	
	
	public boolean finishAfter(State s, Context c, float time) {
		s.removeConstraint(this,c);
		return true;
	}
	
	public boolean applicableBefore(State s, Context c) {
		return true;
	}
	
	public boolean applicableAfter(State s, Context c) {
		return true;
	}
	
	public String toString() {
		return "(== " + id + " " + value + ")";
	}

	
}
